package at.irian.jsfatwork.broker.domain.account;

import at.irian.jsfatwork.broker.domain.BaseEntity;

import javax.persistence.*;
import java.math.BigDecimal;
import java.util.Date;

/**
 * @author Thomas Spiegl
 */
@Entity
public class ClearingAccountPosition extends BaseEntity {

    private BigDecimal amount;

    private Date bookingDateTime;

    private Long id;

    /**
     * Protected access - only ClearingAccount is allowed to create positions.
     */
    protected ClearingAccountPosition() {
    }

    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    @Basic(optional = false)
    public BigDecimal getAmount() {
        return amount;
    }

    public void setAmount(BigDecimal amount) {
        this.amount = amount;
    }
    
    @Basic(optional = false)
    @Temporal(TemporalType.TIMESTAMP)
    public Date getBookingDateTime() {
        return bookingDateTime;
    }

    public void setBookingDateTime(Date bookingDateTime) {
        this.bookingDateTime = bookingDateTime;
    }

    public void accountBalance(ClearingAccountBalance balance) {
        balance.add(amount);
    }

}
